package com.example.tools;

import android.content.Context;

/**
 * Created by Administrator on 2016/9/26.
 */
public class SharePreTools {
    /** 单例存储名称 */
    public static String sharedPreferencesName = "doctor";

    public static void saveInt(Context context, String strName, int intValue) {
        context.getSharedPreferences(sharedPreferencesName, 0).edit().putInt(strName, intValue).commit();
    }

    public static void saveString(Context context, String strName, String strValue) {
        context.getSharedPreferences(sharedPreferencesName, 0).edit().putString(strName, strValue).commit();
    }

    public static void saveLong(Context context, String strName, long longValue) {
        context.getSharedPreferences(sharedPreferencesName, 0).edit().putLong(strName, longValue).commit();
    }

    public static void saveBoolean(Context context, String strName, boolean booleanValue) {
        context.getSharedPreferences(sharedPreferencesName, 0).edit().putBoolean(strName, booleanValue).commit();
    }

    public static int getValue(Context context, String strName, int intDefault) {
        return context.getSharedPreferences(sharedPreferencesName, 0).getInt(strName, intDefault);
    }

    public static String getValue(Context context, String strName, String strDefault) {
        return context.getSharedPreferences(sharedPreferencesName, 0).getString(strName, strDefault);
    }

    public static long getValue(Context context, String strName, long longDefault) {
        return context.getSharedPreferences(sharedPreferencesName, 0).getLong(strName, longDefault);
    }

    public static boolean getValue(Context context, String strName, boolean booleanDefault) {
        return context.getSharedPreferences(sharedPreferencesName, 0).getBoolean(strName, booleanDefault);
    }

    public static void delObject(Context context, String strName) {
        context.getSharedPreferences(sharedPreferencesName, 0).edit().remove(strName).commit();
    }
}
